package com.hc.sss.llz.controller;

import com.hc.sss.common.ResultMap;
import com.hc.sss.pojo.Advertisement;
import com.hc.sss.service.AdvertisementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("advertisement")
public class AdvertisementController {

    @Autowired
    AdvertisementService advertisementService;


    //查询所有广告分页
	@RequestMapping("/findAdvertisementList")
	@ResponseBody
	public ResultMap<Advertisement> findAdvertisementList(Advertisement advertisement,String advEndTime2,Integer page,Integer limit) {
		Map<String, Object> paramMap = new HashMap<>();
		paramMap.put("page", page);
		paramMap.put("limit", limit);
		paramMap.put("advertisement", advertisement);
		paramMap.put("advEndTime2", advEndTime2);
		ResultMap<Advertisement> resultMap = advertisementService.findAdvertisementList(paramMap);
		System.out.println(1);
		return resultMap;
	}
	
	//删除广告
	@RequestMapping("/delAdvertisement")
	@ResponseBody
	public int delAdvertisement(Advertisement advertisement) {
		advertisement.setAdvStatus(-1);
		return advertisementService.updateAdvertisement(advertisement);
	}
	
	//修改广告
	@RequestMapping("/updateAdvertisement")
	@ResponseBody
	public int updateAdvertisement(Advertisement advertisement){
		return advertisementService.updateAdvertisement(advertisement);
	}
	
	//添加广告
	@RequestMapping("/insertAdvertisement")
	@ResponseBody
	public int insertAdvertisement(Advertisement advertisement){
		advertisement.setAdvStatus(1);
		return advertisementService.insertAdvertisement(advertisement);
	}
	
	
	
	
	
	
	
}
